package com.handsome.迭代器模式;

import java.util.Iterator;
import java.util.List;

/**
 * @author niechun
 * @date 2023/3/19 13:06
 */
public class InfoCollegeIterator implements Iterator {
    //以集合的形式存放department;
   private List<Department> departments;
   //开始迭代的位置
    private int index=-1;

    public InfoCollegeIterator(List<Department> departments) {
        this.departments = departments;
    }

    @Override
    public boolean hasNext() {
       if (index>=departments.size()-1){
           return false;
       }
       index+=1;
        return true;
    }

    @Override
    public Object next() {
       return departments.get(index);
    }

    @Override
    public void remove() {

    }
}
